package org.spring.data.jpa.demo.config;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @date 2021/9/6
 * @auther uranus
 */
@Component
public class JPAAuditorAware implements AuditorAware<String> {

    @Override
    public Optional<String> getCurrentAuditor() {
        Snowflake snowflake= IdUtil.getSnowflake();
        String id=snowflake.nextIdStr();
        return Optional.of(id);
    }
}
